package com.itheima.jdk;

import java.io.InputStream;
import java.net.*;

public class JDKGet {
    public static void main(String[] args) throws Exception {
        //1、确定首页url
        String u="http://www.itcast.cn";

        //2、发送请求，获取数据
        URL url = new URL(u);

        //获取一个远程连接对象
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        //2.3 获取数据
        InputStream inputStream = conn.getInputStream();
        int len;
        byte[] bytes = new byte[1024];
        while ((len=inputStream.read(bytes))!=-1){
            System.out.println(new String(bytes,0,len));
        }

        inputStream.close();

    }
}
